<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>访问表单元素</title>
    <script type="text/javascript" src="../js/jquery-3.4.1.min.js"></script>
    <script>
        $(function(){
           $("#btn").click(function(){
              console.log("用户名:"+$("#username").val());
              console.log("密码:"+$("#password").val());
               console.log("用户名:"+$("#username").prop("value"));
               console.log("用户名:"+$("#username").attr("value"));
               console.log("密码:"+$("#password").prop("value"));
              $("#username").val("username");
              $("#password").val("password");
           });
        });
    </script>
</head>
<body>
用户名:<input type="text" id="username"/><br/>
密码:<input type="password" id="password"/><br/>
<button id="btn">提交</button>
</body>
</html>